home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
btrees2.arc
/
BTSTACK.C
< prev
next >
Wrap
Text File
|
1984-12-14
|
690b
|
44 lines
/* btstack */
#include <stdio.h>
#include <btextern.h>
/* stack manipulation routines for the btree system */
#define MAXVAL 50 /* maximum depth of val stack */
static int sp = 0; /* stack pointer */
static int val[MAXVAL]; /* value stack */
int push (f) /* push f onto value stack */
int f;
{
if (sp < MAXVAL)
return (val[sp++] = f);
else {
abort ("ERROR: stack full");
clear ();
return (0);
}
}
int pop () /* pop top value from stack */
{
if (sp > 0)
return (val[--sp]);
else {
abort ("ERROR: stack empty");
clear ();
return (0);
}
}
int clear () /* clear stack */
{
sp = 0;
push (NULL);
push (NULL);
}